#ifndef SWITCHBUTTON_H
#define SWITCHBUTTON_H

#include <QWidget>
#include <QPainter>
#include <QMouseEvent>
#include <QPropertyAnimation>


class SwitchButton : public QWidget
{
    Q_OBJECT
public:
    explicit SwitchButton(QWidget *parent = nullptr);
    ~SwitchButton();


protected:
    void paintEvent(QPaintEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void resizeEvent(QResizeEvent *event) override;

private:

    /* 开关状态 */
    bool m_isOff = true;

    /* 背景 */
    QBrush m_offBgBrush = Qt::gray;
    QBrush m_onBgBrush = Qt::green;

    /* 指示器 */
    QBrush m_offIndicatorBrush = Qt::white;
    QBrush m_onIndicatorBrush = Qt::white;
    QPointF m_indicatorPos;
    QPropertyAnimation* m_indicatorAnimation = nullptr;

    /* 文字 */
    QColor m_textColor = Qt::black;
    QFont m_textFont = QFont("微软雅黑", 16);
    QString m_offText = "OFF";
    QString m_onText = "ON";


signals:

};

#endif // SWITCHBUTTON_H
